﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using DSPL.Common;
using DSPL.Contracts;
using DSPL.Contracts.Command;
using DSPL.Contracts.ViewModel;
using DSPL.Services.Services;
using DSPL.Contracts.Common;
using DSPL.Finac.Common;

namespace DSPL.Finac.ViewModel
{
    public class AreaMasterViewModel : BaseViewModel
    {
        private bool isAreaCodeFocused;
        private bool isAreaNameFocused;

        #region Define properties
       
        public bool IsAreaCodeFocused
        {
            get { return isAreaCodeFocused; }
            set
            {
                isAreaCodeFocused = value;
                this.OnPropertyChanged("IsAreaCodeFocused");
            }
        }

        public bool IsAreaNameFocused
        {
            get { return isAreaNameFocused; }
            set
            {
                isAreaNameFocused = value;
                this.OnPropertyChanged("IsAreaNameFocused");

            }
        }
        #endregion

        #region Constructor
        public AreaMasterViewModel():base()
        {
            MessageTitle =  "Area Master";
        }
        #endregion             

        /// <summary>
        /// Validate mandatory data before save
        /// </summary>
        /// <param name="obj"></param>
        protected override void PreDataValidateExecuted(object obj)
        {
            IsAreaCodeFocused = false;
            IsAreaNameFocused = false;

            if (string.IsNullOrEmpty(CurrentRow["AreaCode"].ToString().Trim() ))
            {
                MessageService.ShowMessage(MessageText.AreaCodeNotEmpty,MessageTitle, MessageType.InfoOK);
                IsAreaCodeFocused = true;
                this.IsValid = false;
                return;
            }

            if (string.IsNullOrEmpty(CurrentRow["AreaName"].ToString().Trim()))
            {
                MessageService.ShowMessage(MessageText.AreaNameNotEmpty, MessageTitle, MessageType.InfoOK);
                IsAreaNameFocused = true;
                this.IsValid = false;
                return;
            }
            this.IsValid = true;
        }
    }
}

